import java.util.Objects;

/**
 * 学生类
 *
 * @author Kevin
 * @date 2019-01-01
 */
public class Student {

    /**
     * 年级
     */
    private int grade;

    /**
     * 班级
     */
    private int cls;

    /**
     * 名
     */
    private String firstName;

    /**
     * 姓
     */
    private String lastName;

    public Student(int grade, int cls, String firstName, String lastName) {
        this.grade = grade;
        this.cls = cls;
        this.firstName = firstName;
        this.lastName = lastName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Student student = (Student) o;
        return grade == student.grade &&
                cls == student.cls &&
                Objects.equals(firstName, student.firstName) &&
                Objects.equals(lastName, student.lastName);
    }

    @Override
    public int hashCode() {
        int b = 31;
        int hash = 0;
        hash = hash * b + +((Integer) grade).hashCode();
        hash = hash * b + +((Integer) cls).hashCode();
        hash = hash * b + +firstName.toLowerCase().hashCode();
        hash = hash * b + +lastName.toLowerCase().hashCode();

        return hash;
    }

}
